<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

/**
 * 巡店计划模型
 *
 * Class Plan
 * @package App\Models
 */
class Plan extends Model
{
    use SoftDeletes;

    protected $fillable = [
        "start",
        "end",
        "shop_id",
        "user_id",
        "status",
        'xun_dian_ji_lu_id',
    ];

    /**
     * 获取关联到门店
     */
    public function shop()
    {
        return $this->hasOne(Shop::class, 'id', 'shop_id');
    }

    /**
     * 获取巡店计划
     *
     * @author Eric
     * @return \Illuminate\Database\Eloquent\Relations\HasOne
     */
    public function XunDianJiLu()
    {
        return $this->hasOne(XunDianJiLu::class, 'id', 'xun_dian_ji_lu_id');
    }

    /**
     * 获取用户
     *
     * @author Eric
     * @return \Illuminate\Database\Eloquent\Relations\HasOne
     */
    public function user()
    {
        return $this->hasOne(User::class, 'id', 'user_id');
    }
}
